<!--策略学堂-->
<template>
  <!-- 列表 -->
  <list class="all bg1" @loadmore="httpSchoolLoading">
  
    <!--刷新-->
    <refresh :display="isRefresh ? 'show' : 'hide'" @refresh="httpSchool" >
      <loading-indicator class="load text1"></loading-indicator>
    </refresh>

    <!--内容-->
    <cell v-for="(item, index) in datas" v-bind:key="index">

      <!-- 内容 -->
      <VSchool :item="item" @click="infoClick"></VSchool>

      <!-- 无更多数据 -->
      <div class="genduo" v-if="pageMax && (index == datas.length - 1)">
        <text class="font22 text3">{{T('没有更多数据')}}</text>
      </div>
    </cell>
  </list>
</template>

<style src="@/_css/style.css" ></style>
<style scoped>
.load {
  height: 40px;
  width: 40px;
  
  margin-top: 20px;
  margin-left: 355px;
}
.genduo {
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 750px;
  height: 100px;
}
</style>

<script>
//组件
import VSchool from '@/square/view/VSchool.vue' 

//功能
import jhttps from "@/_js/https";
import jnavigator from "@/_js/navigator";
import jmodal from "@/_js/modal";
import jtime from "@/_js/time";

import I18N from "@/_i18n/i18n";
var T = I18N.t;

export default {

  components: {
    VSchool,
  },

  data() {
    return {
      T:T,
      pageNo:0, //页码
      pageMax:false, //turn最大页面
      isRefresh:false, //显示刷新
      isLoadinging:false, //显示加载
      datas:[],
    };
  },

  created() {
    this.httpSchool();
  },

  methods: {

    initData(datas) {

      for (let index = 0; index < datas.length; index++) {
        var data = datas[index];
        data.time = jtime.getTime(data.showTime, 'y/M/d H:m');
      }
      return datas;
    },

    /********************************* HTTP*/
    //http学堂列表-刷新
    httpSchool() {
      if (this.isRefresh || this.isLoadinging) return;
      this.isRefresh = true;

      var param = {'pageNo':1};
      jhttps.post("article/queryArticleList", param,true,(data) => {

        this.isRefresh = false;
        if (data.status == 200) {

          data = data.data;
          this.datas = this.initData(data);
          this.pageNo = 1;
          this.pageMax = data.length < 20;
        } else {
          jmodal.toast(data.msg);
        }
      });
    },

    //http学堂列表-加载
    httpSchoolLoading() {
      if (this.pageMax || this.isRefresh || this.isLoadinging) return;
      this.isLoadinging = true;

      var param = {'pageNo': this.pageNo+1};
      jhttps.post("article/queryArticleList",param,true,(data) => {

        this.isLoadinging = false;
        if (data.status == 200) {

          data = data.data;
          var datas = this.initData(data);
          this.datas.push(...datas);
          this.pageNo++;
          this.pageMax = datas.length < 20;
        } else {
          jmodal.toast(data.msg);
        }
      });
    },
    
    /********************************* 点击*/
    //详情
    infoClick(item){
      jnavigator.openNative('schoolInfo', {'articleId':item.articleId});
    },
  },
};

</script>
